var lengthOfLongestSubstring = function (s) {
  const set = new Set()
  const n = s.length
  let left = 0, right = 0;
  let res = 0
  if (s.length <= 1) {
    console.log(s.length, '----');
  }
  while (left < n && right < n) {
    if (set.has(s[right])) {
      set.clear()
      left++
      right = left;
    } else {
      if (s[right]) {
        set.add(s[right])
      }
      res = Math.max(res, set.size)
      right++;
    }
  }
  console.log(res);
};

lengthOfLongestSubstring("pwwkew")